﻿namespace Lib.Configuration.Entitys;
/// <summary>
/// 文件配置类（上传、下载、解压缩）
/// </summary>
public class File {
    /// <summary>
    /// 构造函数
    /// </summary>
    public File() { }
    /// <summary>
    /// 初始化默认值
    /// </summary>
    public void Initialize() {
        if (!Enable.HasValue) {
            Enable = true;
        }
        if (!MaxSize.HasValue) {
            MaxSize = 200;
        }
        if (string.IsNullOrEmpty(Extension)) {
            Extension = "gif,jpg,png,bmp,zip,rar,txt,swf,wmv,avi,wma,mp3,mp4,mid,doc,docx,xls,xlsx,ppt,pptx,pdf";
        }
        if (string.IsNullOrEmpty(Folder)) {
            Folder = "{yyyy}{MM}";
        }
        if (string.IsNullOrEmpty(Rule)) {
            Rule = "{yyyyMMddHHmmss}{RAN}";
        }
        RootDirectory = Configs.ParseDirectory(RootDirectory, Configs.RootDirectory, "Files");
    }
    /// <summary>
    /// 是否允许上传文件
    /// </summary>
    public bool? Enable { get; set; }
    /// <summary>
    /// 上传根目录（配置时“E:/WebSite/Files 或 Files”，输出时“E:/WebSite/Files/”结尾包含“/”）
    /// </summary>
    public string RootDirectory { get; set; }
    /// <summary>
    /// 允许上传的最大文件大小(MB)
    /// </summary>
    public int? MaxSize { get; set; }
    /// <summary>
    /// 允许上传的文件类型(GIF,JPG,PNG,BMP,ZIP,RAR,TXT,SWF,WMV,AVI,WMA,MP3,MID)
    /// </summary>
    public string Extension { get; set; }
    /// <summary>
    /// 路径命名规则
    /// </summary>
    public string Folder { get; set; }
    /// <summary>
    /// 文件命名规则
    /// </summary>
    public string Rule { get; set; }
    /// <summary>
    /// 支持解压缩扩展名列表（如：“.Rar,.Zip,.7z,....”）
    /// </summary>
    public string UnCompressType { get; set; }
    /// <summary>
    /// 默认压缩扩展名（如：“.Zip”或“.RAR”）
    /// </summary>
    public string ZipExtension { get; set; }

}